<template>
  <div>
    <button @click="isShow = !isShow">显示/隐藏</button>
    <!-- appear 为一开始就会触发, name 也为动画的名字如果不写默认就是v v-enter-active/v-leave-active -->
    <transition
            appear
            name="hello"
    >
      <h1 v-show="isShow">你好啊!</h1>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'Animation',
  data() {
    return {
      isShow: true
    }
  }
}
</script>

<style scoped>
  h1 {
    background-color: orange;
  }
  /* 固定的方式 enter 为进入, leave 为离开 v 为默认的名字 */
  .hello-enter-active {
    animation: animation-study 1s linear;
  }

  .hello-leave-active {
    animation: animation-study 1s linear reverse;
  }

  @keyframes animation-study {
    from {
      transform: translateX(100%);
    }

    to {
      transform: translateX(0);
    }
  }
</style>
